#[cfg(test)]
mod tests {
    /// 测试变量绑定和不可变借用规则
    #[test]
    fn test_variable_binding() {
        let x = 5;
        let y = &x;
        assert_eq!(*y, 5, "验证不可变借用规则");
    }

    /// 测试模式匹配解构Option类型的能力
    #[test]
    fn test_pattern_matching() {
        let opt = Some(42);
        match opt {
            Some(n) => assert_eq!(n, 42, "模式匹配应该解构Some值"),
            None => panic!("预期Some值但得到None")
        }
    }

    #[test]
    fn test_if_let_syntax() {
        let some_value = Some(5);
        let mut count = 0;

        if let Some(x) = some_value {
            count += x;
        }
        assert_eq!(count, 5);
    }

    #[test]
    fn test_while_let_syntax() {
        let mut values = vec![Some(1), Some(2), None, Some(3)];
        let mut sum = 0;

        while let Some(Some(num)) = values.pop() {
            sum += num;
        }
        assert_eq!(sum, 5);
    }

    /// 测试闭包的基本语法和类型推断能力
    #[test]
    fn test_closure() {
        let add = |a, b| a + b;
        let result = add(1, 2);
        assert_eq!(result, 3);
    }
}